home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 2 / LSD and 17bit Compendium Deluxe - Volume II.iso / a / prog / misc / date.lha / Date / Oberon / txt / test.mod < prev    next >
Text File  |  1994-08-11  |  14KB  |  388 lines

  1.  MODULE test;
  2.  
  3.  
  4.  IMPORT Date, io, RealInOut;
  5.  
  6.  
  7.  PROCEDURE readintyear() : INTEGER;
  8.  
  9.  VAR
  10.     year    : INTEGER;
  11.  
  12.  BEGIN
  13.    io.WriteString("(integer)year: ");
  14.    io.ReadIntegerOk(year);
  15.    RETURN(year);
  16.  END readintyear;
  17.  
  18.  
  19.  PROCEDURE readshortcardmonth() : SHORTINT;
  20.  
  21.  VAR
  22.     month    : INTEGER;
  23.  
  24.  BEGIN
  25.    io.WriteString("(shortcard)month: "); io.ReadIntegerOk(month);
  26.    RETURN(SHORT(month));
  27.  END readshortcardmonth;
  28.  
  29.  
  30.  PROCEDURE readshortcardday() : SHORTINT;
  31.  
  32.  VAR
  33.     day    : INTEGER;
  34.  
  35.  BEGIN
  36.    io.WriteString("(shortcard)day: "); io.ReadIntegerOk(day);
  37.    RETURN(SHORT(day));
  38.  END readshortcardday;
  39.  
  40.  
  41.  PROCEDURE readweekday() : Date.Weekdays;
  42.  
  43.  VAR
  44.     wday    : INTEGER;
  45.  
  46.  BEGIN
  47.    REPEAT
  48.      io.WriteString("weekday: 1=Monday; ...7=Sunday: ");
  49.      io.ReadIntegerOk(wday);
  50.    UNTIL (wday < 8) AND (wday > -1);
  51.    RETURN(SHORT(wday));
  52.  END readweekday;
  53.  
  54.  
  55.  PROCEDURE readintdays() : INTEGER;
  56.  
  57.  VAR
  58.     days    : INTEGER;
  59.  
  60.  BEGIN
  61.    io.WriteString("(integer)days: ");
  62.    io.ReadIntegerOk(days);
  63.    RETURN(days);
  64.  END readintdays;
  65.  
  66.  
  67.  PROCEDURE readcardyear() : INTEGER;
  68.  
  69.  VAR
  70.     year    : INTEGER;
  71.  
  72.  BEGIN
  73.    io.WriteString("(cardinal)year: "); io.ReadIntegerOk(year);
  74.    RETURN(year);
  75.  END readcardyear;
  76.  
  77.  
  78.  PROCEDURE readlongcarddays() : LONGINT;
  79.  
  80.  VAR
  81.     day    : LONGINT;
  82.  
  83.  BEGIN
  84.    io.WriteString("(longcard)days: "); io.ReadIntOk(day);
  85.    RETURN(day);
  86.  END readlongcarddays;
  87.  
  88.  
  89.  PROCEDURE readshortcardhour() : SHORTINT;
  90.  
  91.  VAR
  92.     hour    : INTEGER;
  93.  
  94.  BEGIN
  95.    io.WriteString("(shortcard)hour: "); io.ReadIntegerOk(hour);
  96.    RETURN(SHORT(hour));
  97.  END readshortcardhour;
  98.  
  99.  
  100.  PROCEDURE readshortcardmin() : SHORTINT;
  101.  
  102.  VAR
  103.     min    : INTEGER;
  104.  
  105.  BEGIN
  106.    io.WriteString("(shortcard)min: "); io.ReadIntegerOk(min);
  107.    RETURN(SHORT(min));
  108.  END readshortcardmin;
  109.  
  110.  
  111.  PROCEDURE readshortcardsec() : SHORTINT;
  112.  
  113.  VAR
  114.     sec    : INTEGER;
  115.  
  116.  BEGIN
  117.    io.WriteString("(shortcard)sec: "); io.ReadIntegerOk(sec);
  118.    RETURN(SHORT(sec));
  119.  END readshortcardsec;
  120.  
  121.  
  122.  PROCEDURE readrealtime() : REAL;
  123.  
  124.  VAR
  125.     jd    : REAL;
  126.     err    : BOOLEAN;
  127.  
  128.  BEGIN
  129.    io.WriteString("(real)time: ");
  130.    err := RealInOut.ReadReal(jd);
  131.    RETURN(jd);
  132.  END readrealtime;
  133.  
  134.  
  135.  PROCEDURE readshortintdegree() : SHORTINT;
  136.  
  137.  VAR
  138.     degree    : INTEGER;
  139.  
  140.  BEGIN
  141.    io.WriteString("(shortint)degree: ");
  142.    io.ReadIntegerOk(degree);
  143.    RETURN(SHORT(degree));
  144.  END readshortintdegree;
  145.  
  146.  
  147.  PROCEDURE readlongcardsecs() : LONGINT;
  148.  
  149.  VAR
  150.     secs    : LONGINT;
  151.  
  152.  BEGIN
  153.    io.WriteString("(longcard)secs: "); io.ReadIntOk(secs);
  154.    RETURN(secs);
  155.  END readlongcardsecs;
  156.  
  157.  
  158.  PROCEDURE readrealmeridian() : REAL;
  159.  
  160.  VAR
  161.     jd    : REAL;
  162.     err    : BOOLEAN;
  163.  
  164.  BEGIN
  165.    io.WriteString("(real)meridian: ");
  166.    err := RealInOut.ReadReal(jd);
  167.    RETURN(jd);
  168.  END readrealmeridian;
  169.  
  170.  
  171.  PROCEDURE readrealpos() : REAL;
  172.  
  173.  VAR
  174.     jd    : REAL;
  175.     err    : BOOLEAN;
  176.  
  177.  BEGIN
  178.    io.WriteString("(real)ps: ");
  179.    err := RealInOut.ReadReal(jd);
  180.    RETURN(jd);
  181.  END readrealpos;
  182.  
  183.  
  184.  VAR
  185.     input,repeat    : INTEGER;
  186.     wd        : Date.Weekdays;
  187.     d,m,h,s        : SHORTINT;
  188.     y        : INTEGER;
  189.     err        : BOOLEAN;
  190.  
  191.  
  192.  BEGIN
  193.    REPEAT
  194.      io.WriteString("----------------------------------------------------------------\n");
  195.      io.WriteString("01 : JulianLeapYear            | 02 : GregorianLeapYear\n");
  196.      io.WriteString("03 : HeisLeapYear              | 04 : JulianMonthDays\n");
  197.      io.WriteString("05 : GregorianMonthDays        | 06 : HeisMonthDays\n");
  198.      io.WriteString("07 : JulianYearDays            | 08 : GregorianYearDays\n");
  199.      io.WriteString("09 : HeisYearDays              | 10 : JulianDayDiff\n");
  200.      io.WriteString("11 : GregorianDayDiff          | 12 : HeisDayDiff\n");
  201.      io.WriteString("13 : JulianDaySmaller          | 14 : GregorianDaySmaller\n");
  202.      io.WriteString("15 : HeisDaySmaller            | 16 : JulianWeekday\n");
  203.      io.WriteString("17 : GregorianWeekday          | 18 : HeisWeekday\n");
  204.      io.WriteString("19 : JulianDaysBeforeWeekday   | 20 : GregorianDaysBeforeWeekday\n");
  205.      io.WriteString("21 : HeisDaysBeforeWeekday     | 22 : JulianDaysAfterWeekday\n");
  206.      io.WriteString("23 : GregorianDaysAfterWeekday | 24 : HeisDaysAfterWeekday\n");
  207.      io.WriteString("25 : JulianDiffDate            | 26 : GregorianDiffDate\n");
  208.      io.WriteString("27 : HeisDiffDate              | 28 : JYearToScaliger\n");
  209.      io.WriteString("29 : GYearToScaliger           | 30 : HYearToScaliger\n");
  210.      io.WriteString("31 : ScaligerYearToJ           | 32 : ScaligerYearToG\n");
  211.      io.WriteString("33 : ScaligerYearToH           | 34 : JSYearToJD\n");
  212.      io.WriteString("35 : GSYearToJD                | 36 : HSYearToJD\n");
  213.      io.WriteString("37 : JDtoMJD                   | 38 : MJDtoJD\n");
  214.      io.WriteString("39 : JulianToJD                | 40 : GregorianToJD\n");
  215.      io.WriteString("41 : HeisToJD                  | 42 : TimeToJD\n");
  216.      io.WriteString("43 : JDToTime                  | 44 : GregorianMoonAge\n");
  217.      io.WriteString("45 : GregorianEaster           | 46 : TimeZoneFactor\n");
  218.      io.WriteString("47 : LMT                       | 48 : TimeToSec\n");
  219.      io.WriteString("49 : SecToTime                 | 50 : JulianWeek\n");
  220.      io.WriteString("51 : GregorianWeek             | 52 : HeisWeek\n");
  221.      io.WriteString("00 : Quit\n");
  222.      io.WriteString("It's your turn: "); io.ReadIntegerOk(input);
  223.      io.WriteString("----------------------------------------------------------------\n");
  224.      REPEAT
  225.        CASE input OF
  226.           0 : ;|
  227.           1 : IF Date.JulianLeapYear(readintyear()) THEN
  228.               io.WriteString("TRUE\n");;
  229.             ELSE
  230.               io.WriteString("FALSE\n");
  231.             END;|
  232.           2 : IF Date.GregorianLeapYear(readintyear()) THEN
  233.               io.WriteString("TRUE\n");;
  234.             ELSE
  235.               io.WriteString("FALSE\n");
  236.             END;|
  237.           3 : IF Date.HeisLeapYear(readintyear()) THEN
  238.               io.WriteString("TRUE\n");;
  239.             ELSE
  240.               io.WriteString("FALSE\n");
  241.             END;|
  242.           4 : io.WriteInt(Date.JulianMonthDays(readshortcardmonth(),readintyear()),3);
  243.             io.WriteLn;|
  244.           5 : io.WriteInt(Date.GregorianMonthDays(readshortcardmonth(),readintyear()),3);
  245.             io.WriteLn;|
  246.           6 : io.WriteInt(Date.HeisMonthDays(readshortcardmonth(),readintyear()),3);
  247.             io.WriteLn;|
  248.           7 : io.WriteInt(Date.JulianYearDays(readintyear()),4);
  249.               io.WriteLn;|
  250.           8 : io.WriteInt(Date.GregorianYearDays(readintyear()),4);
  251.               io.WriteLn;|
  252.           9 : io.WriteInt(Date.HeisYearDays(readintyear()),4);
  253.               io.WriteLn;|
  254.          10 : io.WriteInt(Date.JulianDayDiff(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()),10);
  255.               io.WriteLn;|
  256.          11 : io.WriteInt(Date.GregorianDayDiff(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()),10);
  257.               io.WriteLn;|
  258.          12 : io.WriteInt(Date.HeisDayDiff(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()),10);
  259.               io.WriteLn;|
  260.          13 : IF Date.JulianDaySmaller(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()) THEN
  261.               io.WriteString("TRUE\n");;
  262.             ELSE
  263.               io.WriteString("FALSE\n");
  264.             END;|
  265.          14 : IF Date.GregorianDaySmaller(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()) THEN
  266.               io.WriteString("TRUE\n");;
  267.             ELSE
  268.               io.WriteString("FALSE\n");
  269.             END;|
  270.          15 : IF Date.HeisDaySmaller(readshortcardday(),readshortcardmonth(),readintyear(),readshortcardday(),readshortcardmonth(),readintyear()) THEN
  271.               io.WriteString("TRUE\n");;
  272.             ELSE
  273.               io.WriteString("FALSE\n");
  274.             END;|
  275.          16 : wd := Date.JulianWeekday(readshortcardday(),readshortcardmonth(),readintyear());
  276.           CASE wd OF
  277.             Date.dayerr    : io.WriteString("dayerr!\n");|
  278.             Date.Monday    : io.WriteString("Monday\n");|
  279.             Date.Tuesday   : io.WriteString("Tuesday\n");|
  280.             Date.Wednesday : io.WriteString("Wednesday\n");|
  281.             Date.Thursday  : io.WriteString("Thursday\n");|
  282.             Date.Friday    : io.WriteString("Friday\n");|
  283.             Date.Saturday  : io.WriteString("Saturday\n");|
  284.             Date.Sunday    : io.WriteString("Sunday\n");
  285.               ELSE
  286.                 io.WriteString("Illegal Code!\n");
  287.               END;|
  288.          17 : wd := Date.GregorianWeekday(readshortcardday(),readshortcardmonth(),readintyear());
  289.           CASE wd OF
  290.             Date.dayerr    : io.WriteString("dayerr!\n");|
  291.             Date.Monday    : io.WriteString("Monday\n");|
  292.             Date.Tuesday   : io.WriteString("Tuesday\n");|
  293.             Date.Wednesday : io.WriteString("Wednesday\n");|
  294.             Date.Thursday  : io.WriteString("Thursday\n");|
  295.             Date.Friday    : io.WriteString("Friday\n");|
  296.             Date.Saturday  : io.WriteString("Saturday\n");|
  297.             Date.Sunday    : io.WriteString("Sunday\n");
  298.               ELSE
  299.                 io.WriteString("Illegal Code!\n");
  300.               END;|
  301.          18 : wd := Date.HeisWeekday(readshortcardday(),readshortcardmonth(),readintyear());
  302.           CASE wd OF
  303.             Date.dayerr    : io.WriteString("dayerr!\n");|
  304.             Date.Monday    : io.WriteString("Monday\n");|
  305.             Date.Tuesday   : io.WriteString("Tuesday\n");|
  306.             Date.Wednesday : io.WriteString("Wednesday\n");|
  307.             Date.Thursday  : io.WriteString("Thursday\n");|
  308.             Date.Friday    : io.WriteString("Friday\n");|
  309.             Date.Saturday  : io.WriteString("Saturday\n");|
  310.             Date.Sunday    : io.WriteString("Sunday\n");
  311.               ELSE
  312.                 io.WriteString("Illegal Code!\n");
  313.               END;|
  314.          19 : io.WriteInt(Date.JulianDaysBeforeWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()),2);
  315.           io.WriteLn;|
  316.          20 : io.WriteInt(Date.GregorianDaysBeforeWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()),2);
  317.           io.WriteLn;|
  318.          21 : io.WriteInt(Date.HeisDaysBeforeWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()),2);
  319.           io.WriteLn;|
  320.          22 : io.WriteInt(Date.JulianDaysAfterWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()),2);
  321.           io.WriteLn;|
  322.          23 : io.WriteInt(Date.GregorianDaysAfterWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()),2);
  323.           io.WriteLn;|
  324.          24 : io.WriteInt(Date.HeisDaysAfterWeekday(readshortcardday(),readshortcardmonth(),readintyear(),readweekday()),2);
  325.           io.WriteLn;|
  326.          25 : Date.JulianDiffDate(readshortcardday(),readshortcardmonth(),readintyear(),readintdays(),d,m,y);
  327.               io.WriteInt(d,2); io.WriteString("."); io.WriteInt(m,2); io.WriteString("."); io.WriteInt(y,4); io.WriteLn;|
  328.          26 : Date.GregorianDiffDate(readshortcardday(),readshortcardmonth(),readintyear(),readintdays(),d,m,y);
  329.               io.WriteInt(d,2); io.WriteString("."); io.WriteInt(m,2); io.WriteString("."); io.WriteInt(y,4); io.WriteLn;|
  330.          27 : Date.HeisDiffDate(readshortcardday(),readshortcardmonth(),readintyear(),readintdays(),d,m,y);
  331.               io.WriteInt(d,2); io.WriteString("."); io.WriteInt(m,2); io.WriteString("."); io.WriteInt(y,4); io.WriteLn;|
  332.          28 : io.WriteInt(Date.JYearToScaliger(readintyear()),10);
  333.               io.WriteLn;|
  334.          29 : io.WriteInt(Date.GYearToScaliger(readintyear()),10);
  335.               io.WriteLn;|
  336.          30 : io.WriteInt(Date.HYearToScaliger(readintyear()),10);
  337.               io.WriteLn;|
  338.          31 : io.WriteInt(Date.ScaligerYearToJ(readcardyear()),5);
  339.               io.WriteLn;|
  340.          32 : io.WriteInt(Date.ScaligerYearToG(readcardyear()),5);
  341.               io.WriteLn;|
  342.          33 : io.WriteInt(Date.ScaligerYearToH(readcardyear()),5);
  343.               io.WriteLn;|
  344.          34 : io.WriteInt(Date.JSYearToJD(readcardyear()),10);
  345.               io.WriteLn;|
  346.          35 : io.WriteInt(Date.GSYearToJD(readcardyear()),10);
  347.               io.WriteLn;|
  348.          36 : io.WriteInt(Date.HSYearToJD(readcardyear()),10);
  349.               io.WriteLn;|
  350.          37 : io.WriteInt(Date.JDtoMJD(readlongcarddays()),10);
  351.               io.WriteLn;|
  352.          38 : io.WriteInt(Date.MJDtoJD(readlongcarddays()),10);
  353.               io.WriteLn;|
  354.          39 : io.WriteInt(Date.JulianToJD(readshortcardday(),readshortcardmonth(),readintyear()),10);
  355.               io.WriteLn;|
  356.          40 : io.WriteInt(Date.GregorianToJD(readshortcardday(),readshortcardmonth(),readintyear()),10);
  357.               io.WriteLn;|
  358.          41 : io.WriteInt(Date.HeisToJD(readshortcardday(),readshortcardmonth(),readintyear()),10);
  359.               io.WriteLn;|
  360.          42 : err := RealInOut.WriteReal(Date.TimeToJD(readshortcardhour(),readshortcardmin(),readshortcardsec()),20,10,FALSE);
  361.               io.WriteLn;|
  362.          43 : Date.JDToTime(readrealtime(),h,m,s);
  363.               io.WriteInt(h,2); io.WriteString(":"); io.WriteInt(m,2); io.WriteString(":"); io.WriteInt(s,2); io.WriteLn;|
  364.          44 : io.WriteInt(Date.GregorianMoonAge(readshortcardday(),readshortcardmonth(),readintyear()),2);
  365.               io.WriteLn;|
  366.          45 : Date.GregorianEaster(readintyear(),d,m);
  367.               io.WriteInt(d,2); io.WriteString("."); io.WriteInt(m,2); io.WriteString("."); io.WriteLn;|
  368.          46 : io.WriteInt(Date.TimeZoneFactor(readshortintdegree()),2); io.WriteLn;|
  369.          47 : io.WriteInt(Date.LMT(readlongcardsecs(),readrealmeridian(),readrealpos()),10); io.WriteLn;|
  370.          48 : io.WriteInt(Date.TimeToSec(readshortcardhour(),readshortcardmin(),readshortcardsec()),10); io.WriteLn;|
  371.          49 : Date.SecToTime(readlongcardsecs(),h,m,s);
  372.               io.WriteInt(h,2); io.WriteString(":"); io.WriteInt(m,2); io.WriteString(":"); io.WriteInt(s,2); io.WriteLn;|
  373.          50 : io.WriteInt(Date.JulianWeek(readshortcardday(),readshortcardmonth(),readintyear()),2); io.WriteLn;|
  374.          51 : io.WriteInt(Date.GregorianWeek(readshortcardday(),readshortcardmonth(),readintyear()),2); io.WriteLn;|
  375.          52 : io.WriteInt(Date.HeisWeek(readshortcardday(),readshortcardmonth(),readintyear()),2); io.WriteLn;
  376.        ELSE
  377.          io.WriteString("Wong number! Try again!\n");
  378.        END;
  379.        IF input > 0 THEN
  380.          io.WriteString("0 : Menue; >0 : test again - ");
  381.          io.ReadIntegerOk(repeat);
  382.        ELSE
  383.          repeat := 0;
  384.        END;
  385.      UNTIL repeat = 0;
  386.    UNTIL input = 0;
  387.  END test.
  388.